﻿global using Devonline.Core;
using Devonline.Communication.Abstractions;

namespace Devonline.Communication.Server;

/// <summary>
/// 通讯中心配置项
/// </summary>
public class HostSetting : AppSetting
{
    public HostSetting()
    {
        TransportType = TransportType.NewtonsoftJson;
        CachePrefix = "dcs_";
        Host = "/dcs";
        User = "user";
        Client = "client";
        Receiver = "receiver";
        NoticeIdentityType = IdentityType.Role;
        DefaultExpireTime = AppSettings.UNIT_DAYS_A_YEAR;
    }

    /// <summary>
    /// 传输交互方式
    /// </summary>
    public TransportType TransportType { get; set; }
    /// <summary>
    /// 服务器启动的终结点地址
    /// </summary>
    public string Host { get; set; }
    /// <summary>
    /// 通讯中心使用的获取用户标识的变量名
    /// </summary>
    public string User { get; set; }
    /// <summary>
    /// 通讯中心使用的获取客户端标识的变量名
    /// </summary>
    public string Client { get; set; }
    /// <summary>
    /// 通讯中心使用的获取客户端接收者的变量名
    /// </summary>
    public string Receiver { get; set; }
    /// <summary>
    /// 上线通知开关
    /// </summary>
    public bool OnlineNotice { get; set; }
    /// <summary>
    /// 离线通知开关
    /// </summary>
    public bool OfflineNotice { get; set; }
    /// <summary>
    /// 通知对象, 上下线消息接收对象类型, IdentityType 枚举值, 默认: Role
    /// </summary>
    public IdentityType NoticeIdentityType { get; set; }
    /// <summary>
    /// 通知对象, 上下线消息接收者
    /// </summary>
    public string? NoticeReceiver { get; set; }
    /// <summary>
    /// 离线接收开关, 启用了离线接收, 则有效期内的离线消息会在用户下次上线时发送给用户, 默认开
    /// </summary>
    public bool OfflineReceive { get; set; }
    /// <summary>
    /// 默认过期时间, 用于启用了离线接收后, 用户再次登录时, 通知消息的有效期范围, 单位: 天, 默认一年
    /// </summary>
    public int DefaultExpireTime { get; set; }
}